﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using ExamDemo.Models;

namespace ExamDemo.Data
{
    public class InitializeData : DropCreateDatabaseIfModelChanges<ExamDemoDB>
    {
        // 初始化数据库数据
        protected override void Seed(ExamDemoDB db)
        {
           
            db.Users.AddRange(new List<Users>
            {
                new Users
                {
                    UserName = "小胖",
                    Password = "123"
                },
                new Users
                {
                    UserName = "小花",
                    Password = "123"
                },
                new Users
                {
                    UserName = "小明",
                    Password = "123"
                },
            });


            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    Contert = "小胖来也",
                    FromUserId = 1
                },
                new Messages
                {
                    Contert = "小花来也",
                    FromUserId = 2
                },
                new Messages
                {
                    Contert = "小明来也",
                    FromUserId = 3
                },
            });

            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    Contert = "小胖不胖吖",
                    FromUserId = 2,
                    ToMsgId = 1
                },
                new Comments
                {
                    Contert = "小花不花吖",
                    FromUserId = 1,
                    ToMsgId = 2
                },
                new Comments
                {
                    Contert = "小明不明白",
                    FromUserId = 3,
                    ToMsgId = 3
                },
            });

            db.SaveChanges();

            base.Seed(db);
        }
    }
}